1 using UnityEngine;
2 using
System.Collections;
3
4 public
class CarDriveLeftSideScript : MonoBehaviour {
5
6     
private GameObject startingPoint;
7     
private GameObject endingPoint;
8     
9     
public float speed = 23.0f;
10
11     IronManBehaviorScript behaviorScript;
12     
13     
// Use this for initialization
14     
void Start () {
15         startingPoint = GameObject.Find (
"starting-point");
16         endingPoint = GameObject.Find (
"ending-point");
17
18         GameObject player = GameObject.FindGameObjectWithTag (
"Player");
19         behaviorScript = player.GetComponent<IronManBehaviorScript> ();
20         
21     }
22     
23     
// Update is called once per frame
24     
void Update () {
25         
if (behaviorScript.gameOver == true) {
26             speed =
0;
27         }
28         
this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y, this.transform.position.z - speed * Time.deltaTime);
29         
if (this.transform.position.z < startingPoint.transform.position.z) {
30             
this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y, endingPoint.transform.position.z);
31         }
32         
33     }
34 }


Gõ tìm kiếm nhanh...